<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="./css/element.css" />
    <style>
      body,
      html,
      #app {
        margin: 0;
        padding: 0;
        width: 100%;
        height: 100%;
      }
      body {
        background-size: 100% 100%;
      }
      .row {
        /* width: 1280px; */
        min-height: 30px;
        overflow: hidden;
        border-top: 1px solid #409eff;
        display: flex;
        align-items: center;
        border-right: 1px solid #409eff;
      }
      .col {
        display: inline-block;
        /* height: 100%; */
        /* overflow: hidden; */
        padding: 5px;
        color: #000;
        font-size: 14px;
        box-sizing: border-box;
        min-width: 20px;
        /* text-overflow: ellipsis; */
        /* white-space: nowrap; */
        text-align: center;
      }
      pre {
        /* height: 100%; */
        margin: 0;
      }
      .line {
        display: inline-block;
        width: 1px;
        height: 100%;
        background: #409eff;
      }
      .worksheetnameblock {
        position: fixed;
        bottom: 0;
        font-size: 13px;
        width: 10000px;
        background: rgba(0, 0, 0, 0.2);
        color: #000;
        font-weight: bold;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
      }
      .worksheetname {
        display: inline-block;
        padding: 15px 15px;
        user-select: none;
        /* border-radius: 10px; */
      }
      .worksheetname:hover {
        color: #fff;
        background: rgba(0, 0, 0, 0.4);
      }
      .active {
        color: #fff;
        background: rgba(0, 0, 0, 0.4);
      }
      .worksheet {
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div class="content">
        <div class="worksheet">
          <div
            class="row"
            v-for="(item, indexz) in worksheetItem"
            :style="{height: item[0].height * 5 + 'px', 'border-bottom': indexz === worksheetItem.length - 1 ? '1px solid #409eff' : 'none' }"
          >
            <template v-for="(col,index) in item">
              <div
                v-if="!col.merge"
                :style="{visibility: (col.value || index === 0) ? 'visible' : 'hidden'}"
                class="line"
              ></div>
              <div
                v-if="!col.merge"
                class="col"
                :style="{
            width: col.width * 8 + 'px',
          }"
              >
                <pre>{{ col.value }}</pre>
              </div>
            </template>
          </div>

          <div class="worksheetnameblock">
            <div
              v-for="(item,index) in worksheet"
              class="worksheetname"
              :class="{active: activeindex == index}"
              @click="tabworksheet(index)"
            >
              {{ item.name }}
            </div>
          </div>
        </div>
      </div>
    </div>
    <script src="./js/excelReview.js"></script>
  </body>
</html>
<!-- 引入 Vue -->
<script src="./js/vuenext.js"></script>
<!-- 引入组件库 -->
<script src="./js/element.js"></script>
<script src="./js/axios.js"></script>
<script>
  const App = {
    data() {
      return {
        message: '123',
        worksheet: [],
        worksheetItem: [],
        activeindex: 0,
      };
    },
    mounted() {
      axios.post('/readexcel', {}).then((res) => {
        var workArrWidth = [];
        var workArrHeight = [];
        var newData = res.data;
        if (newData && newData.length > 0) {
          newData.forEach((worksheetz) => {
            var lastWidth = [];
            var lastHeight = [];
            worksheetz.data.forEach((item) => {
              var lastHeightSingle = 0;
              item.forEach((col, index) => {
                if (!lastWidth[index]) {
                  lastWidth[index] = col.width;
                } else {
                  if (lastWidth[index] < col.width) {
                    lastWidth[index] = col.width;
                  }
                }
                if (col.height > lastHeightSingle) {
                  lastHeightSingle = col.height;
                }
                /* if (!lastHeight[index]) {
              lastHeight[index] = col.height;
            } else {
              if (lastHeight[index] < col.height) {
                lastHeight[index] = col.height;
              }
            } */
              });
              lastHeight.push(lastHeightSingle);
            });

            worksheetz.data.forEach((item) => {
              item.forEach((col, index) => {
                col.width = lastWidth[index];
                // col.height = lastHeight[index];
              });
            });
            workArrWidth.push(lastWidth);
            workArrHeight.push(lastHeight);
          });
        }
        this.worksheet = newData;
        this.worksheetItem = newData[0].data;
      });
    },
    methods: {
      tabworksheet: function (index) {
        this.worksheetItem = this.worksheet[index].data;
        this.activeindex = index;
      },
    },
  };

  const app = Vue.createApp(App);
  app.use(ElementPlus);
  app.mount('#app');
</script>
